package com.augurit.common.syslog.web;

import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;
import org.springframework.beans.factory.annotation.Autowired;
import org.springside.modules.orm.Page;

import com.augurit.common.base.action.CrudActionSupport;
import com.augurit.common.base.action.ExtCrudActionSupport;
import com.augurit.common.syslog.service.ISysLoginLogService;
import com.augurit.common.syslog.web.form.SysLoginLogForm;
import com.augurit.common.util.ExtUtils;

@SuppressWarnings("serial")
@Results({
	@Result(name = CrudActionSupport.RELOAD, location = "sys-login-log.action", type = "redirect"),
	@Result(name = CrudActionSupport.SUCCESS, location = "/common/syslog/sys-login-log.jsp")
})
public class SysLoginLogAction extends ExtCrudActionSupport<SysLoginLogForm>{

	@Autowired
	private ISysLoginLogService sysLoginLogService;
	
	private SysLoginLogForm form;
	
	private Long id;
	private Long[] ids;
	
	private Page<SysLoginLogForm> page = new Page<SysLoginLogForm>(15);
	
	/**
	 * 删除记录
	 */
	@Override
	public String delete() throws Exception {
		sysLoginLogService.delete(ids);
		return null;
	}

	/**
	 * 分页查询
	 */
	@Override
	public String list() throws Exception {
		ExtUtils.initPageFromExtGridParam(this.getRequest(), page);
		sysLoginLogService.search(page, form);
		this.extRenderGridJson(page);
		return null;
	}

	/**
	 * 准备页面模型
	 */
	@Override
	protected void prepareModel() throws Exception {
		// TODO Auto-generated method stub
		if( id  != null){
			form = sysLoginLogService.get(id);
		}
		else
			form = new SysLoginLogForm();
	}

	/**
	 * 保存新增或者修改的Form对象
	 */
	@Override
	public String save() throws Exception {
		// TODO Auto-generated method stub
		sysLoginLogService.save(form);
		return null;
	}
	
	/**
	 * 新增或修改
	 */
	public String input() throws Exception {
		this.extRenderFormJson(form);
		return null;
	}

	public SysLoginLogForm getModel() {
		// TODO Auto-generated method stub
		return form;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Page<SysLoginLogForm> getPage() {
		return page;
	}

	public void setPage(Page<SysLoginLogForm> page) {
		this.page = page;
	}

	public Long[] getIds() {
		return ids;
	}

	public void setIds(Long[] ids) {
		this.ids = ids;
	}

}
